-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto_algebra.move #6550
crypto_algebra.move #6550
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive by comment: Is it possible to separate GenericAlgebraicStructuresBasicOperations and Bls12381Structures into 2 separate PRs? Also please add context to the PR's description
@movekevin sorry, this was supposed to be a draft... converted. |
@movekevin that's possible, but the actual functions work only when both features are on. |
aptos-move/framework/aptos-stdlib/sources/cryptography/algebra.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/aptos-stdlib/sources/cryptography/algebra.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/aptos-stdlib/sources/cryptography/algebra.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/aptos-stdlib/sources/cryptography/algebra.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/aptos-stdlib/sources/cryptography/algebra.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/aptos-stdlib/sources/cryptography/algebra_bls12381.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/aptos-stdlib/sources/cryptography/algebra_bls12381.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/aptos-stdlib/sources/cryptography/algebra_bls12381.move
Outdated
Show resolved
Hide resolved
@@ -8,6 +8,71 @@ crate::natives::define_gas_parameters_for_natives!(GasParameters, "aptos_framewo | |||
[.account.create_address.base, "account.create_address.base", 300 * MUL], | |||
[.account.create_signer.base, "account.create_signer.base", 300 * MUL], | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vgao1996, be sure to take a look here.
abort_code: MOVE_ABORT_CODE_NOT_IMPLEMENTED, | ||
}), | ||
} | ||
fn abort_invariant_violated() -> PartialVMError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vgao1996, we often return this when there's an internal error in our natives, due to us not having maintained the right invariants, or due to a library surprising us with an unexpected return value. Be sure to let us know if this doesn't make sense.
aptos-move/framework/aptos-stdlib/sources/cryptography/algebra_bls12381.move
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite some good work. I skimmed over the way how this is added to Move and the libraries, and see no problem. I left a comment on the AIP which should be resolved (the name algebra
for the module is too generic). I wonder whether aptos move test --coverage
was attempted?
assert_eq!(1, ty_args.len()); | ||
let structure_opt = structure_from_ty_arg!(context, &ty_args[0]); | ||
abort_unless_arithmetics_enabled_for_structure!(context, structure_opt); | ||
match structure_opt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's sad that this can't be done on the level of Move via a trait type system, which statically resolves to the right functions. Good example why we later may want this feature in Move.
Yes! It said ~95% coverage. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
Description
This PR implements a Move module for generic field/group operations. The module is described in this AIP.
How to review this PR
First, I'd recommend looking at the following
.move
files, in this order:crypto_algebra.move
-- declares functions for most field/group operationsbls12381_algebra.move
-- declaresstruct
"marker" types for the BLS12-381 scalar field and groupsgroth16.move
-- shows how to use thealgebra.move
module to build a generic Groth16 ZKP verifier that works over any curve; inmove-examples/
Second, take a look over some infrastructure changes:
gas_meter.rs
-- gas version bumpaptos_framework.rs
-- new gas costs for BLS12-381 arithmetic operationsCargo.toml
's -- new dependenciesaptos-move/aptos-vm/src/natives.rs
-- now passes some move_stdlib gas parameters downThird, take a look over the Rust native implementation in
aptos-move/framework/src/natives/cryptography/algebra
:mod.rs
-- creates all the nativesTODOs
MUL
from gas-scripts & re-compute everything.Follow-up post-merge
arkworks
arkworks
#[inline]
functions foralgebra_bls12381.move
if appropriate.